<?php
class tbl_account extends AppModel
{
    public $useTable = 'accounts';
    public $useDbConfig = 'fantasy_hero_kr';
    public $primaryKey = '_id';
    //public $order = array('last_login_date' => 'DESC');

    public function search_account($_account)
    {
        $params = array(
            'conditions' => array(
                'account' => $_account,
            ),
            'fields' => array(
                'account', 'modified','created','os','first_pay','play_time','grade','version','daily_reward_count','banned','crystal','play_time','tutorial','_id'
            ),
        );

        $data = $this->find('all', $params);

        return $data;
    }

    public function search_id($_usn)
    {
        $params = array(
            'conditions' => array(
                '_id' => $_usn
            ),
            'fields' => array(
                'account', 'modified','created','os','first_pay','play_time','grade','version','daily_reward_count','banned','crystal','play_time','tutorial','_id'
            ),
        );

        $data = $this->find('all', $params);

        return $data;
    }

    public function get_total_count()
    {
        $ru_count = $this->find('count');
        $params = array(
            'conditions' => array(
                'block' => 1
            ),
        );
        $block_count = $this->find('count', $params);
        $data = array(
            'ru_count' => $ru_count,
            'block_count' => $block_count
        );

        return $data;
    }

    public function get_nru($_date)
    {
        $params = array(
            'fields' => array('register_date'),
            'conditions' => array(
                'DATE(register_date)' => $_date
            ),
        );
        $data = $this->find('count', $params);

        return $data;
    }

    public function get_dau($_date)
    {
        $params = array(
            'fields' => array('last_login_date'),
            'conditions' => array(
                'DATE(last_login_date)' => $_date
            ),
        );
        $data = $this->find('count', $params);

        return $data;
    }
}